package com.goktech.lesson01.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;


import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2017-09-13.
 */
@Controller
@RequestMapping("login")
public class LoginController {

    //ASDASDASdasdasdasd
    @RequestMapping("")
    public ModelAndView login(){
        return new ModelAndView("login");
    }

    @RequestMapping(value = "/doLogin1",method = {RequestMethod.POST})
    public void doLogin1(HttpServletRequest req){
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        System.out.print("username:" + username + ",password: " + password);

    }

    /*  改改改 啊爱上的撒单身 爱的是大事改改  改改改  */
    @RequestMapping(value = "/doLogin2",method = {RequestMethod.POST})
    public String doLogin2(@RequestParam String username,@RequestParam Integer password){
        if(username.equals("abc")){
            return "redirect:success";
        }else{
            return "redirect:fail";
        }

    }


    @RequestMapping(value = "/success")
    public ModelAndView success(){
        return new ModelAndView("success");
    }

    @RequestMapping(value = "/fail")
    public ModelAndView fail(){
        return new ModelAndView("fail");
    }


}
